package com.asset.dispoal.address.service;

import com.asset.dispoal.address.api.AddressService;
import com.asset.dispoal.address.dto.SysAddressRequest;
import com.asset.dispoal.address.dto.SysAddressResponse;
import com.asset.dispoal.address.service.commom.AddressDeleteCommand;
import com.asset.dispoal.address.service.commom.AddressGetByIdCommand;
import com.asset.dispoal.address.service.commom.AddressInsertCommand;
import com.asset.dispoal.address.service.commom.AddressQueryAllCommand;
import com.asset.dispoal.address.service.commom.AddressUpdateCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tech.mhuang.pacebox.springboot.protocol.Result;

import java.util.List;


/**
 * @author qr
 * @date 2022/2/16$
 */
@Service
public class SysAddressServiceImpl implements AddressService {

    @Autowired
    AddressInsertCommand addressInsertCommand;

    @Autowired
    AddressUpdateCommand addressUpdateCommand;

    @Autowired
    AddressDeleteCommand addressDeleteCommand;
    @Autowired
    AddressQueryAllCommand addressQueryAllCommand;

    @Autowired
    AddressGetByIdCommand addressGetByIdCommand;

    @Override
    public void insert(SysAddressRequest request) {
        addressInsertCommand.execute(request);
    }

    @Override
    public void update(SysAddressRequest request) {
        addressUpdateCommand.execute(request);
    }

    @Override
    public void delete(SysAddressRequest request) {
        addressDeleteCommand.execute(request);
    }

    @Override
    public Result<List<SysAddressResponse>> queryAll(SysAddressRequest request) {
        final Result<List<SysAddressResponse>> execute = addressQueryAllCommand.execute(request);
        return execute;
    }

    @Override
    public Result<SysAddressResponse> queryById(String code) {
        final Result<SysAddressResponse> execute = addressGetByIdCommand.execute(code);
        return execute;
    }
}
